package com.coding.controller;

import com.coding.base.pojo.BaseModel;
import com.coding.service.PlaceService;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @auther wangchenghao
 * @date 2020/7/26
 **/

@Controller
@ResponseBody
@RequestMapping("place")
public class PlaceController {
    @Autowired
    PlaceService placeService;

    @ApiOperation(value = "通过id查询特色景点资源")
    @RequestMapping(value = "/getById", method = {RequestMethod.GET})
    public BaseModel getById(@ApiParam(value = "place_id", required = true) @RequestParam("place_id") int place_id) {
        BaseModel baseModel = new BaseModel();
        try {
            placeService.selectById(place_id, baseModel);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return baseModel;
    }

    @ApiOperation(value = "通过main_place_id查询特色景点资源")
    @RequestMapping(value = "/getByMainId", method = {RequestMethod.GET})
    public BaseModel getByMainId(@ApiParam(value = "main_place_id", required = true) @RequestParam("main_place_id") int main_place_id) {
        BaseModel baseModel = new BaseModel();
        try {
            placeService.selectByMainPlaceId(main_place_id, baseModel);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return baseModel;
    }
}
